package com.anzia.storeback.dao;

import com.anzia.storeback.entity.Collect;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 *@ClassName CollectDao
 *@Description
 *@Author Anzia.
 *@Date 2021/5/29 20:32
 *@Version 1.0
 **/
@Repository
public interface CollectDao {

    // 添加
    @Insert("insert into collect(user_id, product_id, collect_time) values(#{user_id}, #{product_id}, now())")
    void addCollect(int user_id, int product_id);

    // 获得
    @Select("select * from collect where user_id=#{user_id}")
    List<Collect> getCollect(int user_id);

    // 查询
    @Select("select count(1) from collect where user_id=#{user_id} and product_id=#{product_id}")
    int findCollect(int user_id, int product_id);

    // 删除
    @Delete("delete from collect where user_id=#{user_id} and product_id=#{product_id}")
    void deleteCollect(int user_id, int product_id);

}
